This example provides two commands to the user. The first, EnterData, takes a text selection as input, and reads it line for line. Each line should consist of an integer number, followed by a string, trailed by a real number. Each such tuple is entered into a globally anchored linear list, sorted by the integer value. The second command, ListData, generates a text which displays the data currently in the list.
The following text is not an embedded text view, since embedded views which are larger than one page tend to be cumbersome to use. To compile a text like the one below, select its beginning (e.g. double-click on the keyword MODULE), and then execute Compile
list := NIL (* release data structure so that garbage collector can reclaim memory *)
END Reset;
END ObxDb0.
ObxDb0.EnterData
ObxDb0.ListData
ObxDb0.Reset
To try out the example, select the following lines, and then click the left commander above:
1 Cray 14.8
3 NEC 16.6
2 IBM 8.3
Now click the middle commander, as a result a window opens with the sorted input. If you repeat both steps, you'll note that the input has been added to the list a second time, and that consequently every item appears twice in the output.
This example has shown how a text can be scanned symbol by symbol, instead of character by character.